<?php
class Tbl_locat_model extends CI_Model
{

	function __construct()
	{
		parent::__construct();
		$this->load->database();
	}

	function insert($data)
	{
		$this->db->set('locat_nm', $data['locat_nm']);
		$this->db->set('locat_address', $data['locat_address']);
		$this->db->set('email', $data['email']);
		$this->db->set('advert_info', $data['advert_info']);
		$this->db->set('latitude', $data['latitude']);
		$this->db->set('longitude', $data['longitude']);
		$this->db->set('logo_id', $data['logo_id']);
		$this->db->set('advert_flg', $data['advert_flg']);
		$this->db->set('mn_id', $data['mn_id']);
		$this->db->set('user_id', $data['user_id']);
		$this->db->set('created', $data['created']);
		$this->db->set('updated', $data['updated']);
		$this->db->insert('tbl_locat');

		return $this->db->affected_rows();
	}

	function select($id)
	{
		$this->db->where('id', $id);
		$query = $this->db->get('tbl_locat');

		return $query;
	}

	function selectAll()
	{
		$query = $this->db->get('tbl_locat');

		return $query;
	}

	function update($id, $data)
	{
		$this->db->where('id', $data['id']);
		$this->db->set('locat_nm', $data['locat_nm']);
		$this->db->set('locat_address', $data['locat_address']);
		$this->db->set('email', $data['email']);
		$this->db->set('advert_info', $data['advert_info']);
		$this->db->set('latitude', $data['latitude']);
		$this->db->set('longitude', $data['longitude']);
		$this->db->set('logo_id', $data['logo_id']);
		$this->db->set('advert_flg', $data['advert_flg']);
		$this->db->set('mn_id', $data['mn_id']);
		$this->db->set('user_id', $data['user_id']);
		$this->db->set('created', $data['created']);
		$this->db->set('updated', $data['updated']);
		$this->db->update('tbl_locat');

		return $this->db->affected_rows();
	}

	function delete($id)
	{
		$this->db->where('id', $id);
		$this->db->delete('tbl_locat');

		return $this->db->affected_rows();
	}

}